﻿<div ng-init="currentTab='news'" ng-include="'Views/Menu/NewsCalendarEventMenu.html'"></div>

<div>

    <div class="user-inputs">
        <button class="btn-green" ng-click="newsList.addNews();">Add News Item</button><br /><br />
        <form>
            <select class="select-box" ng-model="newsList.newsFilter.category" style="width: 49%; margin-right: 29px;">
                <option value="">News Category</option>
                <option ng-repeat="newsCategory in newsList.newsCategories" value="{{newsCategory.id}}">{{newsCategory.name}}</option>
            </select>
            <input type="text" class="search-inp" placeholder="Search Criteria" ng-model="newsList.newsFilterTemp.term" style="width: 48%;" />
            <input type="submit" class="search-btn" ng-click="newsList.search();" value="" />
        </form>
        <div class="clear">&nbsp;</div>
    </div><br />

    <div ng-show="newsList.newsPaged.totalItemsCount > 0">
        <div style="display: table; width: 789px; float: left;">
            <div class="table-row">
                <div class="table-head" style="width: 40px;"><input type="checkbox" ng-model="newsList.selectAll"></div>
                <div class="table-head width_190"><a href="" ng-click="newsList.changeOrderBy('TitleLowercase');" ng-class="newsList.orderByCol === 'TitleLowercase' ? (newsList.orderByColAsc ? 'sortable_up' : 'sortable_down') : null">News Item</a></div>
                <div class="table-head width_110"><a href="" ng-click="newsList.changeOrderBy('DateCreated');" ng-class="newsList.orderByCol === 'DateCreated' ? (newsList.orderByColAsc ? 'sortable_up' : 'sortable_down') : null">Date Added</a></div>
                <div class="table-head width_130"><a href="" ng-click="newsList.changeOrderBy('AddedByUserNameLoweCase');" ng-class="newsList.orderByCol === 'AddedByUserNameLoweCase' ? (newsList.orderByColAsc ? 'sortable_up' : 'sortable_down') : null">Added by</a></div>
                <div class="table-head width_110"><a href="" ng-click="newsList.changeOrderBy('StatusTextLowercase');" ng-class="newsList.orderByCol === 'StatusTextLowercase' ? (newsList.orderByColAsc ? 'sortable_up' : 'sortable_down') : null">Status</a></div>
                <div class="table-head width_130"><a href="" ng-click="newsList.changeOrderBy('UnpublishedDate');" ng-class="newsList.orderByCol === 'UnpublishedDate' ? (newsList.orderByColAsc ? 'sortable_up' : 'sortable_down') : null">Unpublished Date</a></div>
                <div class="table-head width_110"><a href="" ng-click="newsList.changeOrderBy('AvailableForTextLowercase');" ng-class="newsList.orderByCol === 'AvailableForTextLowercase' ? (newsList.orderByColAsc ? 'sortable_up' : 'sortable_down') : null">Available for</a></div>
            </div>
            <div class="table-row" ng-repeat="item in newsList.newsPaged.items">
                <div class="table-col"><input type="checkbox" ng-model="item.selected"></div>
                <div class="table-col"><a href="" ng-click="newsList.editNews(item.id);" style="overflow:hidden; display:block; max-width: 170px; text-overflow: ellipsis; white-space: nowrap; font-weight: bold;" title="{{item.title}}">{{ item.title && item.title.length > 50 ? item.title.substring(0, 50) + '...' : item.title }}</a></div>
                <div class="table-col">{{item.dateCreated | date: 'MMM d, y'}}</div>
                <div class="table-col">{{item.addedByUserName}}</div>
                <div class="table-col"><span class="green">{{$parent.newsList.newsStatusesDic[item.status].name}}</span></div>
                <div class="table-col">{{item.unpublishedDate | date: 'MMM d, y'}}</div>
                <div class="table-col">{{$parent.newsList.newsAvailabilitiesDic[item.availableFor].name}}</div>
            </div>
        </div>
        <div style="display: table; width: 200px; float: left;">
            <div class="table-row">
                <div class="table-col sel-items">
                    <div class="title-sel-items">
                        News Selected: <span style="color: #24b1a8;">{{ newsList.getSelectedItems().length }}</span>
                    </div>
                    <br /><br />
                    <button class="btn-green" style="width: 120px;" ng-click="newsList.deleteNews();">Delete News</button><br /><br />
                    <button class="btn-green" style="width: 120px;" ng-click="newsList.publishMultipleNews();">Publish News</button>
                </div>
            </div>
        </div>
        <div class="clear">&nbsp;</div>
        <sustainalytics-pager></sustainalytics-pager>
    </div>

    <div ng-show="!newsList.newsPaged || !newsList.newsPaged.items || newsList.newsPaged.items.length == 0" style="text-align: center;">
        <br/>
        <br />
        <b>No articles found matching the search criteria</b>
    </div>
</div>